<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2022/8/12
  Time: 19:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>信息列表</title>
    <script src="js/jquery-3.6.0.js"></script>
    <style>
        a{
            text-decoration: none;
        }
    </style>
</head>
<body>
<div id="app" style="width: 700px;margin: auto">
    <h2  style="width: 450px;margin: auto">新能源汽车动力电池信息</h2>
    <table border="1px" style="text-align: center">
        <tr>
            <td>编号</td>
            <td>车型</td>
            <td>所属城市</td>
            <td>使用单位</td>
            <td>压差报警值</td>
            <td>报警时间</td>
            <td>操作</td>
        </tr>
        <c:forEach items="${requestScope.list}" var="power">
            <tr>
                <td><a href="PowerBatterySelectServlet?opr=update&id=${power.id}">${power.id}</a></td>
                <td>${power.carName}</td>
                <td>${power.cityName}</td>
                <td>${power.userName}</td>
                <td>${power.pressureValue}</td>
                <td>${power.time}</td>
                <td><a onclick="deleteFu(${power.id})">删除</a></td>
            </tr>
        </c:forEach>
    </table>
</div>
<script>
    $(function (){
        // $("table tr").css("background-color","pink");
    })
    var deleteFu = function (id){
        if (confirm("确认要删除吗？")){
            $.ajax({
                url:"PowerBatteryDeleteServlet",
                type:"GET",
                dataType:"text",
                data:{
                    id:id
                },
                success:function (data){
                    if(data==="true"){
                        alert("删除成功")
                    }else {
                        alert("删除失败")
                    }
                    location.href='PowerBatterySelectServlet?opr=all';
                }
            })
        }
    }
</script>
</body>
</html>
